package com.itcc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

@Configuration
public class WebMvcFileUpLoadConfig {

    @Bean   //配置文件上传的Bean
    public MultipartResolver multipartResolver(){

        CommonsMultipartResolver resolver = new CommonsMultipartResolver();
        resolver.setMaxUploadSizePerFile(5 * 1024 * 1024);  //单个文件最大上传大小为5M
        resolver.setMaxInMemorySize(0); //内存中存储文件的最大大小(0表示不使用内存存储文件)
        resolver.setDefaultEncoding("UTF-8");
        return resolver;
    }
}
